package com.tentative.competition.web.controller.schedule.service;

import com.tentative.competition.common.core.controller.BaseController;
import com.tentative.competition.common.core.domain.AjaxResult;
import com.tentative.competition.common.core.result.ApiResult;
import com.tentative.competition.common.core.result.PageResult;
import com.tentative.competition.common.model.schedule.param.*;
import com.tentative.competition.common.model.schedule.resp.ScheduleWorksResp;
import com.tentative.competition.common.model.schedule.resp.WorksGradeListResp;
import com.tentative.competition.schedule.service.ScheduleAwardService;
import com.tentative.competition.schedule.service.ScheduleScoreDetailService;
import com.tentative.competition.schedule.service.ScheduleWorksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @auther: Smile Huang
 * @date: 2023/6/27 20:31
 * @desc:
 * @version: 2.0
 */
@Api(tags ="service-作品评级管理")
@RestController
@RequestMapping("/service/grade")
public class WorksGradeController extends BaseController {

    @Autowired
    private ScheduleWorksService worksService;

    @Autowired
    private ScheduleScoreDetailService scoreDetailService;

    @Autowired
    private ScheduleAwardService awardService;

    @ApiOperation("作品列表-默认进行中的赛程")
    @GetMapping("/list")
    public ApiResult list(WorksGradeListParam param) {
        PageResult<WorksGradeListResp> pageResult = worksService.selectWorksGradeList(param);
        return ApiResult.ofPage(pageResult.getContent(),pageResult.getTotal());
    }


    @ApiOperation("评委打分")
    @PostMapping("/mark")
    public AjaxResult mark(@RequestBody MarkParam param) {
        return AjaxResult.success(scoreDetailService.mark(param));
    }

    @ApiOperation("确认最终得分")
    @PostMapping("/verify-score")
    public AjaxResult verifyScore(@RequestBody VerifyScoreParam param) {
        return AjaxResult.success(scoreDetailService.verifyScore(param));
    }

    @ApiOperation("修改作品最终得分-得分已确认的情况下")
    @PostMapping("/edit-finallyScore")
    public AjaxResult editFinallyScore(@RequestBody EditFinallyScoreParam param) {
        return AjaxResult.success(scoreDetailService.editFinallyScore(param));
    }

    @ApiOperation("设计评级-评奖")
    @PostMapping("/set-rating")
    public AjaxResult setRating(@RequestBody RatingParam param) {
        return AjaxResult.success(scoreDetailService.setRating(param));
    }

    @ApiOperation("作品明细")
    @GetMapping("/worksInfo/{worksId}")
    public AjaxResult getWorksInfo(@PathVariable("worksId") Long worksId) {
        ScheduleWorksResp worksServiceInfo = worksService.getInfo(worksId);
        return AjaxResult.success(worksServiceInfo);
    }

    @ApiOperation("获取奖项配置下拉数据")
    @GetMapping(value = "/awardPullDown/{scheduleId}")
    public AjaxResult getAwardConfig(@PathVariable("scheduleId") Long scheduleId) {
        return AjaxResult.success(awardService.pullDown(scheduleId));
    }

    @ApiOperation("评分明细")
    @GetMapping("/scoreDetail/{worksId}")
    public AjaxResult getScoreDetail(@PathVariable("worksId") Long worksId) {
        return AjaxResult.success(scoreDetailService.getScoreDetail(worksId));
    }

    @ApiOperation("作品打包")
    @GetMapping("/pack/{worksId}")
    public void worksPack(@PathVariable("worksId") Long worksId) {
        worksService.worksPack(worksId);
    }
}
